Gyakorló feladat rendezésre:

Tömb feltöltése n darab véletlen számmal és elrendezése buborék rendezéssel


public class Rendezes{
   public static void main(String[] args){
   int n,i,j,x;
   boolean vcs;
   int[] a=new int[100];
   n=;
   i=0;
   System.out.println("A tomb a rendezes elott");
   while (i<n){
     a[i]=(int)(90*Math.random()+1);
     i=i+1;
     System.out.println("A tomb "+i+". eleme:"+a[i]);
     }
   i=;
   while (i<n){
      j=n-1;
      vcs=;
      while (j>i){
         if (a[j]<a[j-1]){
             x=a[j];
             a[j]=a[j-1];
             a[j-1]=x;
             vcs=;
             }
         j=j-;
      }
   if (vcs==false) break;
   i=i+;
   }
   System.out.println("");
   System.out.println("Rendezes utan")
   i=0;
   while (i<n){
      System.out.println("A tomb "+i+". eleme:"+a[i]);
      i=i+1;
      }
}